'use strict'

let arr = [1,24,87,456,2,6,4];

//arr= [1,32,4];

console.log(arr.sort(function(z,y){
    if(z<y){
        return -1;
    }
    if(z===y){
        return 0;
    }
    if(z>y){
        return 1;
    }
}));
//console.log(arr);
console.log(arr.reverse());


let arr1 = ['汤普森','欧文','字母锅'];

console.log(arr1.sort(function(j,k){
    var b = j.toUpperCase();
    let g = k.toUpperCase();
    if(b<g){
        return -1;
    }
    if(b===g){
        return 0;
    }
    if(b>g){
        return 1;
    }
}));
console.log(arr1.reverse());

let arr3 = ['莫高窟','=','某妖高估娥壁画多！'];

console.log(arr3.every(function(d){
    //return d.length>0;
    return d.toLowerCase();
}));

var adder = {
    base : 1,  
    add : function(a) {
      var f = v => v + this.base;
      return f(a);
    },
    addThruCall: function(a) {
      var f = v => v + this.base;
      var b = {
        base : 2
      };        
      return f.call(b, a);
    }
  };
  
  console.log(adder.add(1));         //  2
  console.log(adder.addThruCall(1)); // 2

  var obj = {
    birth: 1990,
    getAge: function () {
        var b = this.birth; // 1990
        console.log(this);
        let dnm =()=>{
            console.log(this);
        }
        function func(){
            console.log(this);
        }
        return dnm();
    }
};

console.log(obj.getAge());

var hh = [1,746,563,365,35];

console.log(hh.sort(function(x,y){
    if(x<y){
        return 1;
    }
    if(x>y){
        return -1;
    }
    return 0;
}));

let gh = [1,2,34,57];

console.log(gh.sort(function(f,g){
    if(f<g){
        return -1;
    }
    if(f>g){
        return 1;
    }
    return 0;
}));



//'use strict';
var obj = {
  i: 100,
  b: () => console.log(this.i, this),
  c: function() {
    console.log( this.i, this)
  }
}
obj.b(); 
// undefined, Window{...}
obj.c(); 
// 10, Object {...}